import { IOauth2TokenState, IUserDetailInfo } from "@/core/pinia/interface";
import { LoginParams, RefreshTokenParams } from "../api.interface";
import { Http } from "@/core/api/http.service";
/* 微服务授权认证中心匹配模块 */
const oauthPath = "/lc-oauth";
export const login = (params: LoginParams) => {
  return Http.of().post<unknown, IOauth2TokenState>(
    `${oauthPath}/oauth2/token`,
    params,
    {
      headers: {
        Authorization:
          "Basic cml2ZXItbGFrZTo2MzM0YzExZS04NWUxLTQ2N2UtYjg4Yi0yNzE5NmY3Y2RiM2E=",
        "Content-Type": "application/x-www-form-urlencoded"
      }
    }
  );
};
export const refreshToken = (params: RefreshTokenParams) => {
  return Http.of().post<unknown, IOauth2TokenState>(
    `${oauthPath}/oauth2/token`,
    params,
    {
      headers: {
        Authorization:
          "Basic cml2ZXItbGFrZTo2MzM0YzExZS04NWUxLTQ2N2UtYjg4Yi0yNzE5NmY3Y2RiM2E=",
        "Content-Type": "application/x-www-form-urlencoded"
      }
    }
  );
};

export const getUserInfo = () => {
  return Http.of().get<IUserDetailInfo>(`${oauthPath}/oauth2/getUserInfo`);
};
